// 路由规则
// import Home from "../views/Homs/index.vue";
// import Login from "../views/Login";
// import Register from "../views/Register";
// import Search from "../views/Search";
// 用懒加载的话就不用引入这些组件了
const routes = [
  {
    path: "/",
    redirect: "/home",
  },
  {
    path: "/home",
    name: "home",
    // component: Home,
    component: () => import("@/views/Homs"),
    meta: {
      //如果是在home组件当中，在meta中能找到isHidden 这个属性,且值为true
      isHiddenNav: true, // 这就相当于是一种状态，根据这个来区分是home组件还是search组件
    },
  },
  {
    name: "search",
    // path: "/search",//这个是query参数的形式
    path: "/search/:keyword?", //这个?类似正则中的？,表示1个或者是1个都没有
    // component: Search,
    component: () => import("@/views/Search"),
  },
  {
    path: "/login",
    name: "login",
    // component: Login,
    component: () => import("@/views/Login"),

    meta: {
      isHiddenFooter: true,
    },
  },

  {
    path: "/register",
    name: "register",
    // component: Register,
    component: () => import("@/views/Register"),

    meta: {
      isHiddenFooter: true,
    },
  },
  {
    path: "/detail/:id",
    name: "detail",
    //路由懒加载的方式加载组件
    component: () => import("@/views/Detail"),
    // 在此处规则当中添加一个props:true属性的时候，就可以在对应的组件中使用props:[]来接收
    props: true, //所以可以通过props来获取参数值
  },
  {
    name: "addcartsuccess",
    path: "/addcartsuccess",
    component: () => import("@/views/AddCartSuccess"),
  },
  {
    name: "shopcart",
    path: "/shopcart",
    component: () => import("@/views/ShopCart"),
  },
  {
    name: "trade",
    path: "/trade",
    component: () => import("@/views/Trade"),
  },
  {
    name: "center",
    path: "/center",
    component: () => import("@/views/Center"),
  },
  {
    name: "paysuccess",
    path: "/paysuccess",
    component: () => import("@/views/PaySuccess"),
  },
  {
    name: "pay",
    path: "/pay",
    component: () => import("@/views/Pay"),
  },
];

export default routes;
